<h1>Listing Posts</h1>

<table>
  <tr>
	<th>Photos</th>
  <% for column in Post.content_columns %>
    <th><%= column.human_name %></th>
  <% end %>
  </tr>
  
<% for post in @posts %>
  <tr>
	<td>
	<%= post.photos.each do |photo| h(photo.thumbnail_url) end %>
	</td>
	<% for column in Post.content_columns %>
    	<td><%=h post.send(column.name) %></td>
	<% end %>
	
    <td><%= link_to 'Show', :controller => 'admin', :action => 'show', :id => post %></td>
    <td><%= link_to 'Edit', :controller => 'admin', :action => 'edit', :id => post %></td>
    <td><%= link_to 'Destroy', { :controller => 'admin', :action => 'destroy', :id => post }, :confirm => 'Are you sure?', :method => :post %></td>
  </tr>
<% end %>
</table>

<%= link_to 'Previous page', { :page => @post_pages.current.previous } if @post_pages.current.previous %>
<%= link_to 'Next page', { :page => @post_pages.current.next } if @post_pages.current.next %> 

<br />

<%= link_to 'New post', :action => 'new' %>
